package wysiwyg.shapes
{
	import mx.binding.utils.BindingUtils;
	
	import wysiwyg.objectHandles.RectangleHandles;

	public class RectangleShape extends ShapeBase
	{
		public function RectangleShape()
		{
			super();
		}
		
		override protected function createChildren():void
		{
			shapeHandles=new RectangleHandles();
			var rectHandles:RectangleHandles=shapeHandles as RectangleHandles;
			addChild(shapeHandles);
			
			rectHandles.xToUse=x;
			rectHandles.yToUse=y;
			rectHandles.width=width;
			rectHandles.height=height;
			rectHandles.positionToCurrentShape();
			
			
			BindingUtils.bindProperty(shapeHandles,"visible",this,"selected");
			BindingUtils.bindProperty(this,"width",shapeHandles,"width");
			BindingUtils.bindProperty(this,"height",shapeHandles,"height");
			BindingUtils.bindProperty(this,"x",shapeHandles,"xToUse");
			BindingUtils.bindProperty(this,"y",shapeHandles,"yToUse");
			BindingUtils.bindProperty(this,"rotation",shapeHandles,"rotationToUse");
		}
		override protected function updateDisplayList(w:Number, h:Number):void
		{
			graphics.clear();
			super.updateDisplayList(w,h);
			graphics.drawRect(0, 0, w, h);
			graphics.endFill();
		}
	}
}